package slices
{
	import flash.events.MouseEvent;
	
	import global.$uiRoot;
	
	import ui.ShopDialog;
	import ui.UIShopDialogItem;
	
	public class Shopping extends TimeSlice
	{
		public var dialog:ShopDialog; 
		
		public function Shopping()
		{
			super();
		}
		
		override public function onStart() {
			dialog = new ShopDialog();
			$uiRoot.addChild(dialog);
			for each (var item:UIShopDialogItem in dialog.items) {
				item.addEventListener(MouseEvent.ROLL_OVER, onMouseOverItem);
				item.addEventListener(MouseEvent.ROLL_OUT, onMouseOutItem);
				item.addEventListener(MouseEvent.CLICK, onClickItem);
			}
		}
		
		public function onClickItem(e:MouseEvent):void {
			var item:UIShopDialogItem = e.currentTarget as UIShopDialogItem;
		}
		
		public function onMouseOverItem(e:MouseEvent):void {
			var item:UIShopDialogItem = e.currentTarget as UIShopDialogItem;			
		}
		
		public function onMouseOutItem(e:MouseEvent):void {
			var item:UIShopDialogItem = e.currentTarget as UIShopDialogItem;			
		}
		
		override public function onEnd():void {
			for each (var item:UIShopDialogItem in items) {
				item.addEventListener(MouseEvent.CLICK, onClickItem);
				item.addEventListener(MouseEvent.CLICK, onClickItem);
			}			
		}
	}
}